﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using WAD.WEB.AppCode;
using WAD.DAL;
using WAD.Model;

namespace WAD.WEB.Client
{
    public partial class Item_Article : WebBase
    {
        int shareid, article_id, advert_id;
        protected string title, content, url, type, logo, date, click, phone, advert_ids, authorId = "0";
        
        protected void Page_Load(object sender, EventArgs e)
        {
            article_id = Parse.Int("article_id", 0);
            type = Parse.String("type", "");
            shareid = Parse.Int("shareid", 0);

            GetArticle();  //站内链接类型
            if (string.IsNullOrEmpty(logo))
                logo = WJXConfig.Path.URL + "/client/img/cover.jpg";

            if (logo.ToLower().IndexOf("http") == -1)
                logo = WJXConfig.Path.URL + logo;  //外部链接的图片(从正文里抓取的)
        }

        protected string GetIntro(int len)
        {
            if (string.IsNullOrEmpty(content))
                return "";
            string intro = QD.WX.Utill.Util.RemoveHtml(content);
            if (intro.Length > len)
                return intro.Substring(0, len);
            return intro;
        }

        void GetArticle()
        {
            if (article_id < 1) return;
            Dictionary<string, object> map = DaoArticle.GetDetail(article_id);
            if (map != null)
                Set(article_id, advert_id, Convert.ToString(map["title"]), Convert.ToString(map["logo"]), Convert.ToString(map["content"]), Convert.ToString(map["date"]), Convert.ToString(map["click"]), url, "1", Convert.ToString(map["user_id"]));
        }


        void Set(int _article_id, int _advert_id, string _title, string _logo, string _content, string _date, string _click, string _url, string _type, string _authorId)
        {
            article_id = _article_id;
            advert_id = _advert_id;
            title = _title;
            logo = _logo;
            content = _content;
            date = _date;
            click = _click;
            url = _url;
            type = _type;
            authorId = _authorId;
        }
    }
}